package com.allianz.webapps.controllers;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.frame.utils.PropertiesUtil;
@Controller
@RequestMapping(value="main")
public class GetResourcePath {
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	//http://localhost:9000/pad_marketing/main/path.action?path=wechatpreview
	//http://localhost:9000/pad_marketing/main/path.action?path=domain

	//https://pts.allianz.com.cn/pad_marketing/main/path.action?path=domain
	@RequestMapping("/path")
	@ResponseBody
	public Map<String,Object> getpath(@RequestParam(value="jsonParam")String jsonParam,HttpServletRequest request,HttpServletResponse response){
		logger.info("getPath的****************"+request.getSession().getId());
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("result",PropertiesUtil.getProperty((String)JSONObject.fromObject(jsonParam).get("path")));
		return map;
	}

	//https://pts.allianz.com.cn/pad_marketing/main/value.action?path=domain
	@RequestMapping("/value")
	@ResponseBody
	public String getvalue(String jsonParam,HttpServletRequest request,HttpServletResponse response){
		String path = request.getParameter("path");
		return PropertiesUtil.getProperty(path);
	}

}